//
//  ViewController.swift
//  football_game
//
//  Created by 吴翰林 on 2019/9/9.
//  Copyright © 2019 吴翰林. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var a_num: UILabel!
    @IBOutlet weak var b_num: UILabel!
    @IBOutlet weak var a_violation_num: UILabel!

    @IBOutlet weak var b_violation_num: UILabel!
    
    var anum = 0;
    var bnum = 0;
    @IBAction func a_add(_ sender: Any) {
        
        anum += 1
        a_num.text = "\(anum)"
    }
    @IBAction func b_add(_ sender: Any) {
        bnum += 1
        b_num.text = "\(bnum)"
        
    }
    @IBAction func a_return(_ sender: Any) {
        
       
        if anum > 0{
             anum -= 1
            a_num.text = "\(anum)"
        }
    }
    @IBAction func b_return(_ sender: Any) {
        
        if bnum > 0 {
            bnum -= 1
            b_num.text = "\(bnum)"
        }
        
        
    }
    @IBAction func a_violation(_ sender: Any) {
        let anum = a_violation_num.text;
        let num = Int(anum!);
        a_violation_num.text = "\(num!+1)"
        
    }
    @IBAction func b_violation(_ sender: Any) {
        let anum = b_violation_num.text;
        let num = Int(anum!);
        b_violation_num.text = "\(num!+1)"
        
    }
    @IBAction func a_violation_return(_ sender: Any) {
        let anum = a_violation_num.text;
        let num = Int(anum!);
        if num != 0 {
            a_violation_num.text = "\(num!-1)"
        }    }
    @IBAction func b_violation_return(_ sender: Any) {
        let bnum = b_violation_num.text;
        let num = Int(bnum!);
        if num != 0 {
            b_violation_num.text = "\(num!-1)"
        }
        
    }
    @IBAction func num_return(_ sender: Any) {
        anum = 0
        bnum = 0
        a_num.text = "\(anum)"
        b_num.text = "\(bnum)"
        
    }

    @IBAction func vio_returm(_ sender: Any) {
        a_violation_num.text = "0"
        b_violation_num.text = "0"
        
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }


}

